﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using ArbabTravelsERP.Models;
using System.Data.SqlClient;
namespace ArbabTravelsERP.DAL
{
    public class SearchDAL
    {
        DataUtility du = new DataUtility();

        public DataTable SearchCandidateDetails(SearchModel search)
        {
            try
            {
                SqlParameter[] param = new SqlParameter[16];
                SqlParameter ALL = new SqlParameter("@ALL", search.ALL);
                SqlParameter ANY = new SqlParameter("@ANY", search.ANY);
                SqlParameter EXCLUDING = new SqlParameter("@EXCLUDING", search.EXCLUDING);
                SqlParameter EDUCATION_TYPE_ID = new SqlParameter("@EDUCATION_DEGREE", search.MUL_EDUCATION_TYPE_ID);
                SqlParameter SPECIALIZATION_TYPE_ID = new SqlParameter("@SPECIALIZATION", search.MUL_SPECIALIZATION_TYPE_ID);
                SqlParameter MIN_YEAR_OF_PASSING_EDU = new SqlParameter("@MIN_PASSING_YEAR", search.MIN_YEAR_OF_PASSING_EDU);
                SqlParameter MAX_YEAR_OF_PASSING_EDU = new SqlParameter("@MAX_PASSING_YEAR", search.MAX_YEAR_OF_PASSING_EDU);
                SqlParameter MIN_YEAR_OF_PASSING_EXP = new SqlParameter("@MIN_EXPERIENCE", search.MIN_YEAR_OF_PASSING_EXP);
                SqlParameter MAX_YEAR_OF_PASSING_EXP = new SqlParameter("@MAX_EXPERIENCE", search.MAX_YEAR_OF_PASSING_EXP);
                SqlParameter STATE_CODE = new SqlParameter("@STATE_CODE", search.MUL_STATE_CODE);
                SqlParameter CITY_CODE = new SqlParameter("@CITY_CODE", search.MUL_CITY_CODE);
                SqlParameter INDUSTRY_ID = new SqlParameter("@COMPANY_SPECIALIZATION", search.MUL_INDUSTRY_ID);
                SqlParameter DESIGNATION_ID = new SqlParameter("@MIN_AGE", search.MUL_DESIGNATION_ID);
                SqlParameter LANGUAGE_ID = new SqlParameter("@MAX_AGE", search.MUL_LANGUAGE_ID);
                SqlParameter RESUME_NOT_VIEWED = new SqlParameter("@RESUME_NOT_VIEWED", search.RESUME_NOT_VIEWED);
                SqlParameter CONDITIONAL_OPERATOR = new SqlParameter("@CONDITIONAL_OPERATOR", "PORTAL_SEARCH");

                param[0] = ALL;
                param[1] = ANY;
                param[2] = EXCLUDING;
                param[3] = EDUCATION_TYPE_ID;
                param[4] = SPECIALIZATION_TYPE_ID;
                param[5] = MIN_YEAR_OF_PASSING_EDU;
                param[6] = MAX_YEAR_OF_PASSING_EDU;
                param[7] = MIN_YEAR_OF_PASSING_EXP;
                param[8] = MAX_YEAR_OF_PASSING_EXP;
                param[9] = STATE_CODE;
                param[10] = CITY_CODE;
                param[11] = INDUSTRY_ID;
                param[12] = DESIGNATION_ID;
                param[13] = LANGUAGE_ID;
                param[14] = RESUME_NOT_VIEWED;
                param[15] = CONDITIONAL_OPERATOR;

                return du.ExecuteDataTable("StoredProcedure", "PROC_PORTAL_SEARCH", param);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}